/*
 * Sesame Inc.
 * Copyright (c) 2009 All Rights Reserved.
 */
package com.sesame.controller;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

import com.sesame.domain.AlbumTag;
import com.sesame.service.AlbumService;

/**
 * @author voidman
 * 
 */
public class AlbumTagController extends AbstractController {

    private AlbumService albumService;
    private Integer albumId = null;

    public void setAlbumService(AlbumService albumService) {
        this.albumService = albumService;
    }

    protected ModelAndView handleRequestInternal(HttpServletRequest request,
            HttpServletResponse response) throws Exception {

        albumId = Integer.parseInt(request.getParameter("albumId"));
        String tag = request.getParameter("tag");

        Map model = new HashMap();
        if (tag != null) {
            albumService.newAlbumTag(albumId, tag, model);
        }

        List<AlbumTag> albumTagList = albumService.listAlbumTag(albumId);
        model.put("albumTagList", albumTagList);
        model.put("albumId", albumId);

        return new ModelAndView("albumTag", model);

    }

}